package edu.bw.service.impl;

import edu.bw.dao.ProductDao;
import edu.bw.po.Product;
import edu.bw.utils.TransactionManager;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service;

import javax.sql.DataSource;
import java.util.List;

@Setter
@Service
public class ProductServiceImpl02  {

    @Autowired
   private ProductDao productDao;

    @Autowired
    private DataSourceTransactionManager transactionManager;

    public void updateProduct(Product product) {
//        try {
//            transactionManager.beginTransaction();
//            productDao.updateProduct(product);
//            transactionManager.commit();
//        } catch (Exception e) {
//            transactionManager.rollback();
//            throw new RuntimeException(e);
//        }finally {
//            transactionManager.release();
//        }
        int i=1/0;
        productDao.updateProduct(product);
    }

    public List<Product> findAll() {
        return productDao.findAll();
    }
}
